package com.hgw.Demo02CommandPattern.ExamplesUndoOperation;

/**
 * Data time:2021/12/16 20:35
 * StudentID:2019112118
 * Author:hgw
 * Description: 请求发送者
 */
public class CalculatorForm {
    private AbstractCommand command;

    public void setCommand(AbstractCommand command) {
        this.command = command;
    }

    // 调用命令对象execute()方法执行运算
    public void compute(int value) {
        int i = command.execute(value);
        System.out.println("执行运算，运算结果为：" + i);
    }

    // 调用命令对象的undo()方法执行撤销
    public void undo() {
        int i = command.undo();
        System.out.println("执行撤销，运算结果为：" + i);
    }
}
